var t = getApp();

Page({
    data: {
        language: "",
        inputsData: "",
        show1: !1,
        goodList: [],
        chooseGoods: null,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        loading: !1
    },
    onLoad: function(t) {
        this.initData(), this.getRecommendGoods();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.loading ? console.log("没有更多数据") : this.getMoreData();
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {},
    initData: function() {
        this.setData({
            inputsData: "",
            show1: !1,
            goodList: [],
            chooseGoods: null
        }), this.data.inputs = "";
    },
    inpbtn: function(t) {
        var a = t.detail;
        this.data.inputs = a;
    },
    inpbtnclear: function() {
        this.setData({
            inputsData: ""
        }), this.data.inputs = "";
    },
    chooseGood: function(t) {
        var a = t.currentTarget.dataset.id;
        this.setData({
            chooseGoods: a
        });
    },
    gotoRelease: function() {
        if (console.log(t._isTextEmpty(this.data.chooseGoods)), t._isTextEmpty(this.data.chooseGoods)) wx.showToast({
            title: "选择的商品为空",
            icon: "none",
            duration: 1500
        }); else {
            var a = getCurrentPages();
            a[a.length - 2].setGoodsId(this.data.chooseGoods), wx.navigateBack();
        }
    },
    getRecommendGoods: function() {
        var a = this;
        this.data.isLoadMore = !0, this.data.page = 1, this.data.total_page = 0, this.data.loading = !1;
        var o = t.getNetAddresss("plugin.circle.frontend.circle-invitation.search-goods");
        t._getNetWork({
            url: o,
            data: {
                page: 1,
                goods_name: this.data.inputs
            },
            success: function(o) {
                var e = o.data;
                console.log(e), 1 == e.result ? (a.setData({
                    goodList: e.data.data
                }), a.data.total_page = e.data.last_page) : t.tips(e.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, o = t.getNetAddresss("plugin.circle.frontend.circle-invitation.search-goods"), e = {
            goods_name: this.data.inputs,
            page: this.data.page
        };
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page ? this.setData({
            loading: !0
        }) : (this.data.page = this.data.page + 1, t._getNetWork({
            url: o,
            data: e,
            success: function(t) {
                var o = t.data;
                if (1 == o.result) {
                    var e = o.data.data;
                    a.setData({
                        goodList: a.data.goodList.concat(e)
                    });
                } else a.data.page = a.data.page - 1, a.data.loading = !0, a.data.isLoadMore = !1;
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    }
});